﻿using Architecture.Api.Application.Command.RoleCommand;
using Architecture.Domain;
using Architecture.Domain.RBAC;
using Architecture.Service;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.RoleHandler
{
    public class RoleCreateCommandHandler : IRequestHandler<RoleCreateCommand, int>
    {
        private readonly IRoleService _roleService;

        public RoleCreateCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }

        public async Task<int> Handle(RoleCreateCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.AddAsync(new Role() { RoleName = request.RoleName });
        }
    }
}
